#define _CRT_SECURE_NO_WARNINGS 1

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 1e6 + 7;
int n;
int a[N];
int fa[N];

int find(int x)
{
    if (fa[x] == x) return x;
    else fa[x] = find(fa[x]);
    return fa[x];
}

void Union(int u, int v)
{
    u = find(u);
    v = find(v);
    if (u == v) return;
    fa[u] = v;
}

void solve()
{
    cin >> n;
    int mx = 0;
    unordered_map<int, int> mp;
    for (int i = 1;i <= n;i++)
    {
        cin >> a[i];
        fa[i] = i;
        mp[a[i]] = i;
        mx = max(mx, a[i]);
    }
    vector<bool> exit(mx + 1, false);
    for (int i = 1;i <= n;i++)
    {
        exit[a[i]] = true;
    }

    for (int y = 1;y * y <= mx / 2;y++)
    {
        for (int x = y + 1;x * x <= 1.5 * mx;x++)
        {
            if (gcd(x, y) != 1)continue;
            if (x % 2 == y % 2)continue;

            int z = y * y + x * x;
            int u = 2 * x * y;
            int v = x * x - y * y;

            vector<int> tmp;
            if (z <= mx && exit[z]) tmp.push_back(mp[z]);
            if (v <= mx && exit[v]) tmp.push_back(mp[v]);
            if (u <= mx && exit[u]) tmp.push_back(mp[u]);

            if (tmp.size() >= 2)
            {
                int root = find(tmp[0]);
                for (int i = 1;i < tmp.size();i++)
                {
                    Union(root, tmp[i]);
                }
            }
        }
    }

    unordered_set<int> ans;
    for (int i = 1;i <= n;i++)
    {
        ans.insert(find(i));
    }

    cout << ans.size() << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

